﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace peta
{
    class Program
    {
        static void Main(string[] args)
        {
            string optiune;
            while (true)
            {
                Console.WriteLine("1. Adaugare client");
                Console.WriteLine("2. Achizitionare masina");
                Console.WriteLine("3. Vizualizare clienti");
                Console.WriteLine("4. Vizualizare lista masini pentru un anumit client");
                Console.WriteLine("5. Sterge masina");
                Console.WriteLine("6. Exit");
                
                optiune = Console.ReadLine();
                switch (optiune)
                {
                    case "1":
                        Console.Clear();
                        addClient();
                        Console.Clear();
                        break;
                    case "2":
                        Console.Clear();
                        carForExistingClient();
                        Console.Clear();
                        break;
                    case "3":
                        Console.Clear();
                        Console.WriteLine("\nClienti:\n");
                        Server.getInstance().afiseazaClienti();
                        
                        break;
                    case "4":
                        Console.Clear();
                        showCarList();
                        
                        break;
                    case "6":
                        Console.WriteLine("exiting...");
                        Environment.Exit(0);
                        break;
                    case "5":
                         Console.WriteLine("Pentru care client?");
                            Server.getInstance().afiseazaClienti();
                            Console.WriteLine("nume: ");
                            string nume;
                            nume = Console.ReadLine();
                            Client c1 = Server.getInstance().gasesteClient(nume);   // il caut dupa nume
                            c1.stergeMasina();
                            break;
                }
            }
        }

        static void carForExistingClient()
        {
            Console.WriteLine("Pentru care client?");
            Server.getInstance().afiseazaClienti();
            Console.WriteLine("nume: ");
            string nume;
            nume = Console.ReadLine();
            Client c1 = Server.getInstance().gasesteClient(nume);   // il caut dupa nume
            Console.WriteLine("Ce masina? Introduceti indexul doar\n");
            Console.WriteLine("1. Mini");
            Console.WriteLine("2. Coupe");
            Console.WriteLine("3. Sedan");
            string Car;
            Car = Console.ReadLine();
            switch (Car)
            {
                case "1":
                    c1.adaugaCar(new MiniFactory().Get_Car());        //   si adaug Car
                    break;
                case "2":
                    c1.adaugaCar(new CoupeFactory().Get_Car());        //   si adaug Car
                    break;
                case "3":
                    c1.adaugaCar(new SedanFactory().Get_Car());        //   si adaug Car
                    break;
            }
            

        }
        static void showCarList()
        {
            Console.WriteLine("Pentru care client?");
            Server.getInstance().afiseazaClienti();
            Console.Write("nume: ");
            string nume;
            nume = Console.ReadLine();

            Client c1 = Server.getInstance().gasesteClient(nume);   // il caut dupa nume
            c1.showCarList();

        }
        static void addClient()
        {
            string nume;
            int varsta;
            Console.WriteLine("nume client:");
            nume = Console.ReadLine();
            Console.WriteLine("varsta client:");
            Int32.TryParse(Console.ReadLine(),out varsta);
            Client c = new Client(nume, varsta);

            Server.getInstance().addClient(c);  // adaug la lista de clienti
                       
        }
    }
}
